
<template>
  <PPMPage v-if="pageData.length > 0"  :formData="formData" @load-data="load" @goback="closeFun"  @on-sumbit="submitFun" :pageData="pageData">
    <!-- <template slot="footer" class="dialog-footer">
      <el-row>
        <el-col :span="24" class="text-center">
          <el-button type="primary" size="medium" @click="submitFun"
            >保存</el-button
          >
          <el-button size="medium" @click="closeFun">取消</el-button>
        </el-col>
      </el-row>
    </template> -->
  </PPMPage>
</template>
<script>
import ppmmixin from "@/mixins/ppmmixin.js";
import ppmTaskInit from "@/mixins/custorder/ppmTaskInit";
import CustOrderService from "@/api/order/CustOrderService";
import OrderService from "@/api/order/OrderService";
import { mapState } from "vuex";
import requestUtil from "@/utils/requestEnc";
import pageShowDetail from "@/utils/pageShowDetail";
export default {
  name: "ChangePPM",
  mixins: [ppmTaskInit,ppmmixin],
  data() {
    return {
      newcustOrder:[],
      result: [],
      formLabelWidth: "120px",
      fullscreenLoading: false,
      ppmParams: {},
      orderTask: "",
      orderTasks: {},
    };
  },
  computed: {
    ...mapState("orders", ["orderPosInfo"]),
    ...mapState("user", ["user", "busiManagerId", "custManagerId"]),
  },
  props: {
    ODKInfo: {
      type: Object,
      default: () => {
        return {};
      },
    },
    CTOInfo: {
      type: [Object,Array],
      default: () => {
        return [];
      },
    },
  },
  async mounted() {
    var custOrder = JSON.parse(localStorage.getItem("custOrder_select"));
    this.newcustOrder=custOrder;
    if (this.CTOInfos.length > 0) {
      var orderItemIds = "";

      for (var i = 0; i < this.CTOInfos.length; i++) {
        if (i == 0) {
          orderItemIds += this.CTOInfos[i].orderItemId;
        } else {
          orderItemIds += "," + this.CTOInfos[i].orderItemId;
        }
      }
      }
     this.orderItemIds = orderItemIds;

    //  localStorage.setItem("cacheInfo", JSON.stringify({
    //    productId: this.CTOInfo[0].prodId,
    //    taskId:this.ODKInfo.taskId,
    //    OrgId:this.user.orgId,
    //    serviceOfferId:this.CTOInfo[0].offerId,
    //    orderItemIds:orderItemIds

    //  }));

    // sessionStorage.setItem("proName", "zfhs10450");

    // let ppmCondition = {
    //   offerId: this.CTOInfo[0].prodOfferId,
    //   productId: this.CTOInfo[0].prodId,
    //   prodName: this.CTOInfo[0].offerName,
    //   serviceOfferId: "-1", //新装所有产品固定值
    //   modType: "50200003", //新装所有产品固定值
    //   //optionId: "TACHE00050001", //新装所有产品固定值
    //   optionId: this.ODKInfo.taskId,
    // };
    // sessionStorage.setItem("ppmCondition", JSON.stringify(ppmCondition));
    //设置属性
    // this.productName(ppmCondition);
    // sessionStorage.setItem("proName", "zfhs10450");



    // let temp = {
    //   custId: custOrder.custId,
    //   orderSource: "ORDER",
    //   custSoNumber: custOrder.custSoNumber,
    //   orderItemIds: orderItemIds,
    //   taskId:this.ODKInfo.taskId
    // };
    // this.setPageOfferDetail(temp);

      // var custSoNumber = this.CTOInfos[0].custSoNumber;
      // var batchNbr = this.CTOInfos[0].batchNbr;
      // var custId = this.CTOInfos[0].custId;
      // var taskId = this.CTOInfos[0].taskId;

      // this.orderItemIds = orderItemIds;

      // let usersMsg = {
      //   acceptUserId: this.user.staffId,
      //   acceptUserOrg: this.user.orgId,
      //   systemUserId: this.user.sysUserId,
      //   dealType: 234,
      //   orderItemId: this.CTOInfos[0].orderItemId,
      //   orderAuditId: this.CTOInfos[0].orderAuditId,
      // };

      // var scopeInfos = [];
      // scopeInfos.push({ scope: "orderTasks" });
      // var custSoNumber = this.CTOInfo[0].custSoNumber;
      // var batchNbr = this.CTOInfo[0].batchNbr;
      // var custId = this.CTOInfo[0].custId;


      // 工单级别dealType:1 销售品级别dealType:234

      //  this.formData["10461371-100012677"].show = false;

      //  var handOrgId = this.CTOInfo[0].handOrgId;
      //  if(handOrgId == "1944640"){
      //    this.formData["10461371-100013338"].disabled = "disabled";
      //    this.formData["10461371-100012523"].disabled = "disabled";
      //    this.formData["10461371-100012569"].disabled = "disabled";
      //  }


    // }

  },
  methods: {
    load(formData){
      
    },
    async setPageOfferDetail(temp) {
      
      let res = await OrderService.qryPageOfferDetail(temp);
      
      if (res.resultCode == "0") {
        pageShowDetail.RewObject(
          res,
          this.formData,
          temp
        );
        this.inputModeChange();
      }
    },
    async submitFun() {
      
      
      let base = {
        custOrderId:this.newcustOrder.custOrderId,
        custSoNumber: this.CTOInfos[0].custSoNumber, //流水号  从上个页面带回
        custId: this.CTOInfos[0].custId,
        orderItemIds: this.orderItemIds,
        taskId: this.ODKInfo.taskId,
        orderAuditId: this.CTOInfos[0].orderAuditId,
        oneOrmany: "one",
        //orderTaskId: this.orderTaskId,
        userId: "__STAFF_ID__",
        //orderItemId: this.orderItemIds,
        //orderItemSeq: this.CTOInfos[0].orderItemSeq,
        offerType:"dkyw",
        prodOfferId:this.CTOInfos.prodOfferId,

      };
      
      let param = requestUtil.paramEnc(this.formData, base);
      console.log("param===", JSON.stringify({
        ...param,
        ...base,
      }));

      const result = await CustOrderService.saveTariffVerification({
        ...param,
        ...base,
      });

      try {
        if (result.meta.resultCode == 0) {
          this.$message({
            type: "success",
            message: "保存成功!",
          });
          this.$emit("update:show", false);
        } else {
          this.$message({
            showClose: true,
            message: result.meta.resultMsg,
            type: "error",
          });
        }
      } catch {
        this.$message({
          showClose: true,
          message: "code:" + result.code + "  msg:" + result.msg,
          type: "error",
        });
      }
    },
    closeFun() {
      this.$emit("close");
    },
  }
};
</script>
<style scoped>
</style>



